<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Navo Portable Library: navo/algorithm/linear/linked/dllnk.h源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- 制作者 Doxygen 1.7.3 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">Navo Portable Library&#160;<span id="projectnumber">Ver 1.0.20120827</span></div>
   <div id="projectbrief">Provides generic platform independent facilities.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="modules.html"><span>模块</span></a></li>
      <li><a href="annotated.html"><span>数据结构</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>全局定义</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>navo/algorithm/linear/linked/dllnk.h</h1>  </div>
</div>
<div class="contents">
<a href="dllnk_8h.html">浏览该文件的文档。</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */</span>
<a name="l00011"></a>00011 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* #ifdef _MSC_VER */</span>
<a name="l00014"></a>00014 
<a name="l00015"></a>00015 <span class="preprocessor">#ifndef __NV_DLLNK__</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#define __NV_DLLNK__</span>
<a name="l00017"></a>00017 <span class="preprocessor"></span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &quot;<a class="code" href="cdef_8h.html" title="Definitions and declarations for common constants, types, variables.">../../../port/cdef.h</a>&quot;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00021"></a>00021 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00022"></a>00022 <span class="preprocessor">#endif </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l00023"></a>00023 
<a name="l00038"></a><a class="code" href="struct____dllnk__node.html">00038</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct____dllnk__node.html" title="双向线形链表节点">__dllnk_node</a> {
<a name="l00040"></a><a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf">00040</a>     <span class="keyword">struct </span><a class="code" href="struct____dllnk__node.html" title="双向线形链表节点">__dllnk_node</a>* <a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>;
<a name="l00042"></a><a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb">00042</a>     <span class="keyword">struct </span><a class="code" href="struct____dllnk__node.html" title="双向线形链表节点">__dllnk_node</a>* <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00043"></a>00043 }<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf04d58a524b222e00f3874ac37d28a40" title="节点">dllnk_node</a>, *<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0dfcd15adc915116e6cbfada89e0b2d5" title="迭代器">dllnk_iter</a>;
<a name="l00044"></a>00044 
<a name="l00049"></a><a class="code" href="structdllnk__head.html">00049</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00051"></a><a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61">00051</a>     <span class="keyword">struct </span><a class="code" href="struct____dllnk__node.html" title="双向线形链表节点">__dllnk_node</a>* <a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>;
<a name="l00052"></a>00052 }<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>;
<a name="l00053"></a>00053 
<a name="l00062"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaba46055af405e695c603e14df05be38f">00062</a> <span class="preprocessor">#define DLLNK_HEAD(name) dllnk_head name = {NULL}</span>
<a name="l00063"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga08e2aeaf4c5fde424c509d3053e2fa6c">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define DLLNK_NODE(name) dllnk_node name = {NULL, NULL}</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span>
<a name="l00071"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9355ccdf941b5c303dee60ebb4303440">00071</a> <span class="keyword">typedef</span> int (*<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9355ccdf941b5c303dee60ebb4303440" title="单参数回调函数指针">dllnk_pr1</a>)(<a class="code" href="struct____dllnk__node.html" title="双向线形链表节点">dllnk_node</a>*);
<a name="l00072"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae215b02fef9242b63d82bfbc2f56e630">00072</a> <span class="keyword">typedef</span> int (*<a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae215b02fef9242b63d82bfbc2f56e630" title="双参数回调函数指针">dllnk_pr2</a>)(<a class="code" href="struct____dllnk__node.html" title="双向线形链表节点">dllnk_node</a>*, dllnk_node*);
<a name="l00073"></a>00073 
<a name="l00086"></a>00086 NV_API <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa16130c327a3a1a2ae085901c42e2d48" title="判断链表结构是否正常">dllnk_check</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, dllnk_iter* loop_entry);
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 <span class="preprocessor">#define DLLNK_CHECK_PASS    0 </span><span class="comment">/* 正常 */</span>
<a name="l00089"></a>00089 <span class="preprocessor">#define DLLNK_CHECK_LOOP    1 </span><span class="comment">/* 有非法环路 */</span>
<a name="l00090"></a>00090 <span class="preprocessor">#define DLLNK_CHECK_LINK    2 </span><span class="comment">/* 有节点的前驱指针不正确 */</span>
<a name="l00091"></a>00091 
<a name="l00103"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadd5be2ac140080aaff50f132c56ccb67">00103</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadd5be2ac140080aaff50f132c56ccb67" title="初始化表头">dllnk_init</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105     head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a> = NULL;
<a name="l00106"></a>00106 }
<a name="l00107"></a>00107 
<a name="l00122"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac69bb96ee42b0bd76935a66ee2ba3a57">00122</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac69bb96ee42b0bd76935a66ee2ba3a57" title="判断表是否为空">dllnk_empty</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00123"></a>00123 {
<a name="l00124"></a>00124     <span class="keywordflow">return</span> !head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>;
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126 
<a name="l00127"></a>00127 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> __dllnk_singular(dllnk_node* front)
<a name="l00128"></a>00128 {
<a name="l00129"></a>00129     <span class="keywordflow">return</span> (front &amp;&amp; !front-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>);
<a name="l00130"></a>00130 }
<a name="l00131"></a>00131 
<a name="l00146"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0e4ed2cf1d80f3aaeb48eb51cc04d4cb">00146</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0e4ed2cf1d80f3aaeb48eb51cc04d4cb" title="判断表是否只有单个节点">dllnk_singular</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148     <span class="keywordflow">return</span> __dllnk_singular(head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>);
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150 
<a name="l00173"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaeb569329348a99148bb31c1ae41f8b5f">00173</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaeb569329348a99148bb31c1ae41f8b5f" title="判断表是否可以排序">dllnk_sortable</a>(dllnk_iter begin, dllnk_iter end)
<a name="l00174"></a>00174 {
<a name="l00175"></a>00175     <span class="keywordflow">return</span> (begin != end &amp;&amp; begin-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a> != end);
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 
<a name="l00207"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae04e825309cae3e10caf0f64980bcf45">00207</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae04e825309cae3e10caf0f64980bcf45" title="判断表是否可以序列化">dllnk_serialable</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00208"></a>00208 {
<a name="l00209"></a>00209     <span class="keywordflow">return</span> !!head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>;
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211 
<a name="l00219"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34">00219</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(dllnk_iter <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, dllnk_iter <a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>)
<a name="l00220"></a>00220 {   <span class="comment">/* 强制连接prev节点和next节点(next可以为空节点) </span>
<a name="l00221"></a>00221 <span class="comment">     * (1) next不为空 </span>
<a name="l00222"></a>00222 <span class="comment">     * --(prev)--  (next)-- ===&gt; --(prev)--(next)--</span>
<a name="l00223"></a>00223 <span class="comment">     * (2) next为空 </span>
<a name="l00224"></a>00224 <span class="comment">     * --(prev)--  (null) ===&gt; --(prev)-(null)</span>
<a name="l00225"></a>00225 <span class="comment">     */</span>
<a name="l00226"></a>00226     prev-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a> = <a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>;
<a name="l00227"></a>00227     <span class="keywordflow">if</span> (next)
<a name="l00228"></a>00228         next-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a> = <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230 
<a name="l00242"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac01b762b32d894b386224a98ded5a03e">00242</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac01b762b32d894b386224a98ded5a03e" title="在两个节点之间插入一个新节点">dllnk_insert_between</a>(dllnk_node* newly, 
<a name="l00243"></a>00243                                                 dllnk_iter <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, 
<a name="l00244"></a>00244                                                 dllnk_iter <a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>)
<a name="l00245"></a>00245 {   <span class="comment">/* 强制连接prev节点和next节点，并在两者之间插入newly节点</span>
<a name="l00246"></a>00246 <span class="comment">     * (1) prev节点和next节点原来未连接 </span>
<a name="l00247"></a>00247 <span class="comment">     *       (newly)</span>
<a name="l00248"></a>00248 <span class="comment">     *                   ===&gt; --(prev)-(newly)-(next)--</span>
<a name="l00249"></a>00249 <span class="comment">     * --(prev) (next)--</span>
<a name="l00250"></a>00250 <span class="comment">     * (2) prev节点和next节点原来已连接 </span>
<a name="l00251"></a>00251 <span class="comment">     *       (newly)</span>
<a name="l00252"></a>00252 <span class="comment">     *                   ===&gt; --(prev)-(newly)-(next)--</span>
<a name="l00253"></a>00253 <span class="comment">     * --(prev)-(next)--</span>
<a name="l00254"></a>00254 <span class="comment">     */</span>
<a name="l00255"></a>00255     newly-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a> = <a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>;
<a name="l00256"></a>00256     <span class="keywordflow">if</span> (next)
<a name="l00257"></a>00257         next-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a> = newly;
<a name="l00258"></a>00258     prev-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a> = newly;
<a name="l00259"></a>00259     newly-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a> = <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00260"></a>00260     <span class="comment">/* 上面的是性能优化后的版本，实际过程同下：</span>
<a name="l00261"></a>00261 <span class="comment">     * dllnk_link(prev, newly);</span>
<a name="l00262"></a>00262 <span class="comment">     * dllnk_link(newly, next);</span>
<a name="l00263"></a>00263 <span class="comment">     *</span>
<a name="l00264"></a>00264 <span class="comment">     * (1)连接prev节点与newly节点  (2)再连接newly节点与next节点</span>
<a name="l00265"></a>00265 <span class="comment">     *          (newly)                    (newly)</span>
<a name="l00266"></a>00266 <span class="comment">     *          /                          /    \</span>
<a name="l00267"></a>00267 <span class="comment">     *    --(prev)  (next)--         --(prev)  (next)--</span>
<a name="l00268"></a>00268 <span class="comment">     */</span>
<a name="l00269"></a>00269 }
<a name="l00270"></a>00270 
<a name="l00285"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9df2ed836a2efa15737b4043cf06e897">00285</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9df2ed836a2efa15737b4043cf06e897" title="插入节点到指定位置">dllnk_insert</a>(dllnk_iter pos, dllnk_node* newly)
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac01b762b32d894b386224a98ded5a03e" title="在两个节点之间插入一个新节点">dllnk_insert_between</a>(newly, pos-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, pos);
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289 
<a name="l00306"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0244c8a2f2488e82461c9ca7d960f57c">00306</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0244c8a2f2488e82461c9ca7d960f57c" title="擦除节点">dllnk_erase</a>(dllnk_iter entry)
<a name="l00307"></a>00307 {   <span class="comment">/* 将entry节点从表中移除</span>
<a name="l00308"></a>00308 <span class="comment">     *                        (entry)</span>
<a name="l00309"></a>00309 <span class="comment">     *  -()-(entry)-()- ===&gt; </span>
<a name="l00310"></a>00310 <span class="comment">     *                       --()--()--</span>
<a name="l00311"></a>00311 <span class="comment">     */</span>
<a name="l00312"></a>00312     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(entry-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, entry-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>);
<a name="l00313"></a>00313 }
<a name="l00314"></a>00314 
<a name="l00315"></a>00315 NV_API <span class="keywordtype">void</span> __dllnk_free(dllnk_iter begin, dllnk_iter end, 
<a name="l00316"></a>00316                         <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9355ccdf941b5c303dee60ebb4303440" title="单参数回调函数指针">dllnk_pr1</a> erase_handler);
<a name="l00317"></a>00317 
<a name="l00328"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3abf11e0008f6f25163fb6176f8a83dd">00328</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3abf11e0008f6f25163fb6176f8a83dd" title="清空区域">dllnk_erases</a>(dllnk_iter begin, 
<a name="l00329"></a>00329                             dllnk_iter end, <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9355ccdf941b5c303dee60ebb4303440" title="单参数回调函数指针">dllnk_pr1</a> erase_handler)
<a name="l00330"></a>00330 {
<a name="l00331"></a>00331     dllnk_iter <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a> = begin-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00332"></a>00332     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(prev, end);
<a name="l00333"></a>00333     <span class="keywordflow">if</span> (erase_handler)
<a name="l00334"></a>00334         __dllnk_free(begin, end, erase_handler);
<a name="l00335"></a>00335 }
<a name="l00336"></a>00336 
<a name="l00345"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae3a257dc7738b2c38a794fa78231bf18">00345</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae3a257dc7738b2c38a794fa78231bf18" title="清空表">dllnk_clear</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9355ccdf941b5c303dee60ebb4303440" title="单参数回调函数指针">dllnk_pr1</a> erase_handler)
<a name="l00346"></a>00346 {
<a name="l00347"></a>00347     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3abf11e0008f6f25163fb6176f8a83dd" title="清空区域">dllnk_erases</a>(head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>, NULL, erase_handler);
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349 
<a name="l00356"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadfcd92624be83b1645bfba02ffdbe273">00356</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gadfcd92624be83b1645bfba02ffdbe273" title="在表首添加节点">dllnk_push_front</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, dllnk_node* newly)
<a name="l00357"></a>00357 {
<a name="l00358"></a>00358     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac01b762b32d894b386224a98ded5a03e" title="在两个节点之间插入一个新节点">dllnk_insert_between</a>(newly, (dllnk_iter)head, head-&gt;front);
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360 
<a name="l00366"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga347023d92cb9ca9721c05440bd1b7d2f">00366</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga347023d92cb9ca9721c05440bd1b7d2f" title="移除表首节点">dllnk_pop_front</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00367"></a>00367 {
<a name="l00368"></a>00368     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>((dllnk_iter)head, head-&gt;front-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>);
<a name="l00369"></a>00369 }
<a name="l00370"></a>00370 
<a name="l00386"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa20782f9b1767435d0f16dd0de0c870a">00386</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa20782f9b1767435d0f16dd0de0c870a" title="在两个节点之间插入多个连续节点">dllnk_splice_between</a>(
<a name="l00387"></a>00387     dllnk_iter <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, dllnk_iter <a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>, 
<a name="l00388"></a>00388     dllnk_iter first_prev, dllnk_iter first, 
<a name="l00389"></a>00389     dllnk_iter last, dllnk_iter last_next)
<a name="l00390"></a>00390 {   <span class="comment">/* 将first节点至last节点的部分从旧表(B表)移接到新表(A表)中 </span>
<a name="l00391"></a>00391 <span class="comment">     * (从first到last是按next方向)</span>
<a name="l00392"></a>00392 <span class="comment">     * A:  -(prev)-(next)-      </span>
<a name="l00393"></a>00393 <span class="comment">     * B: -(first_prev)-(first)-...-(last)-(last_next)-</span>
<a name="l00394"></a>00394 <span class="comment">     * to:</span>
<a name="l00395"></a>00395 <span class="comment">     * A: -(prev)-(first)-...-(last)-(next)-</span>
<a name="l00396"></a>00396 <span class="comment">     * B: -(first_prev)-(last_next)-</span>
<a name="l00397"></a>00397 <span class="comment">     */</span>
<a name="l00398"></a>00398     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(last, next);
<a name="l00399"></a>00399     prev-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a> = first;
<a name="l00400"></a>00400     first-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a> = <a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00401"></a>00401     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(first_prev, last_next);
<a name="l00402"></a>00402 }
<a name="l00403"></a>00403 
<a name="l00420"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga66f8f6ca8e8861cbb461005b6e71f54b">00420</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga66f8f6ca8e8861cbb461005b6e71f54b" title="在两个节点之间插入多个连续节点">dllnk_splice</a>(dllnk_iter pos, 
<a name="l00421"></a>00421                         dllnk_iter first, dllnk_iter last)
<a name="l00422"></a>00422 {
<a name="l00423"></a>00423     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa20782f9b1767435d0f16dd0de0c870a" title="在两个节点之间插入多个连续节点">dllnk_splice_between</a>(pos-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, pos, first-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, first, last, last-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>);
<a name="l00424"></a>00424 }
<a name="l00425"></a>00425 
<a name="l00432"></a>00432 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga59e49397ff2d1a45b313db980d4bba59" title="统计表的节点数量">dllnk_count</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head);
<a name="l00433"></a>00433 
<a name="l00442"></a>00442 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga809cd392faca17774a7508fdce1382c3" title="计算两个节点的迭代距离">dllnk_distance</a>(dllnk_iter first, dllnk_iter last);
<a name="l00443"></a>00443 
<a name="l00452"></a>00452 NV_API dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaddc2551f2a2069b7aed6165e7027c3fb" title="给迭代器增加一段距离或减小一段距离">dllnk_advance</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, dllnk_iter cur, <span class="keywordtype">int</span> dist);
<a name="l00453"></a>00453 
<a name="l00461"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga13f6fe571e79098c177e287054559c81">00461</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga13f6fe571e79098c177e287054559c81" title="根据正向索引得到迭代器">dllnk_at</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, <span class="keyword">const</span> <span class="keywordtype">size_t</span> index)
<a name="l00462"></a>00462 {
<a name="l00463"></a>00463     <span class="keywordflow">return</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaddc2551f2a2069b7aed6165e7027c3fb" title="给迭代器增加一段距离或减小一段距离">dllnk_advance</a>(head, head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>, index);
<a name="l00464"></a>00464 }
<a name="l00465"></a>00465 
<a name="l00473"></a>00473 NV_API <span class="keywordtype">size_t</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf375dfd2e992dac1e5341420cb0489d5" title="计算迭代器的正向索引">dllnk_index_of</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, dllnk_iter itr);
<a name="l00474"></a>00474 
<a name="l00480"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa9b47ea57c67cc60454e87d3e5e93f07">00480</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa9b47ea57c67cc60454e87d3e5e93f07" title="初始化节点">dllnk_node_init</a>(dllnk_node* entry)
<a name="l00481"></a>00481 {
<a name="l00482"></a>00482     entry-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a> = NULL;
<a name="l00483"></a>00483     entry-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a> = NULL;
<a name="l00484"></a>00484 }
<a name="l00485"></a>00485 
<a name="l00493"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga1afe3a368e765520c5b3897bc3000aed">00493</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga1afe3a368e765520c5b3897bc3000aed" title="用新节点替换目标节点">dllnk_iter_replace</a>(dllnk_node* victim, dllnk_node* newly)
<a name="l00494"></a>00494 {   <span class="comment">/* 用newly节点替换表中的victim节点</span>
<a name="l00495"></a>00495 <span class="comment">     *      (newly)                 (victim)</span>
<a name="l00496"></a>00496 <span class="comment">     *                    ===&gt;</span>
<a name="l00497"></a>00497 <span class="comment">     * --()-(victim)-()--      --()-(newly)-()--</span>
<a name="l00498"></a>00498 <span class="comment">     */</span>
<a name="l00499"></a>00499     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac01b762b32d894b386224a98ded5a03e" title="在两个节点之间插入一个新节点">dllnk_insert_between</a>(newly, victim-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, victim-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>);
<a name="l00500"></a>00500 }
<a name="l00501"></a>00501 
<a name="l00502"></a>00502 NV_API <span class="keywordtype">void</span> __dllnk_iter_swap(
<a name="l00503"></a>00503     dllnk_iter aprev, dllnk_iter a, dllnk_iter anext, 
<a name="l00504"></a>00504     dllnk_iter bprev, dllnk_iter b, dllnk_iter bnext);
<a name="l00505"></a>00505 
<a name="l00512"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0cbe2317d338652e25137962c8651cee">00512</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga0cbe2317d338652e25137962c8651cee" title="交换两个节点">dllnk_iter_swap</a>(dllnk_iter a, dllnk_iter b)
<a name="l00513"></a>00513 {
<a name="l00514"></a>00514     __dllnk_iter_swap(a-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, a, a-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>, b-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>, b, b-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>);
<a name="l00515"></a>00515 }
<a name="l00516"></a>00516 
<a name="l00523"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga79d42c804f4faa777de813864441bb68">00523</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga79d42c804f4faa777de813864441bb68" title="用新表头替换目标表头">dllnk_replace</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* victim, <a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* newly)
<a name="l00524"></a>00524 {   <span class="comment">/* 用newly头替换表中的victim头</span>
<a name="l00525"></a>00525 <span class="comment">     *      [newly]                 [victim]</span>
<a name="l00526"></a>00526 <span class="comment">     *                    ===&gt;</span>
<a name="l00527"></a>00527 <span class="comment">     * [victim]-(front)--      [newly]-(front)--</span>
<a name="l00528"></a>00528 <span class="comment">     */</span>
<a name="l00529"></a>00529     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>((dllnk_iter)newly, victim-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>);
<a name="l00530"></a>00530 }
<a name="l00531"></a>00531 
<a name="l00532"></a>00532 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> __dllnk_swap(dllnk_iter a, dllnk_iter afront, 
<a name="l00533"></a>00533                                 dllnk_iter b, dllnk_iter bfront)
<a name="l00534"></a>00534 {   <span class="comment">/* 交换a、b两个头</span>
<a name="l00535"></a>00535 <span class="comment">     * --(aback)-[a]-(afront)--       --(aback)-[b]-(afront)--</span>
<a name="l00536"></a>00536 <span class="comment">     *                         ===&gt;</span>
<a name="l00537"></a>00537 <span class="comment">     * --(bback)-[b]-(bfront)--       --(bback)-[a]-(afront)--</span>
<a name="l00538"></a>00538 <span class="comment">     */</span>
<a name="l00539"></a>00539     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(b, afront);
<a name="l00540"></a>00540     <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga3be6eee788ebd39efd1a0111cd5ceb34" title="链接两个节点">dllnk_link</a>(a, bfront);
<a name="l00541"></a>00541 }
<a name="l00542"></a>00542 
<a name="l00549"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gab5fb46bc689b5163f4f4ab27bd12ae4d">00549</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gab5fb46bc689b5163f4f4ab27bd12ae4d" title="交换两个表头">dllnk_swap</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* a, <a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* b)
<a name="l00550"></a>00550 {
<a name="l00551"></a>00551     __dllnk_swap((dllnk_iter)a, a-&gt;front, (dllnk_iter)b, b-&gt;front);
<a name="l00552"></a>00552 }
<a name="l00553"></a>00553 
<a name="l00563"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga1a8328b32cceaba4e63f13891352e8e6">00563</a> <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga1a8328b32cceaba4e63f13891352e8e6" title="判断一个节点是否存在于表中">dllnk_exist</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, dllnk_iter itr)
<a name="l00564"></a>00564 {
<a name="l00565"></a>00565     <span class="keywordflow">return</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf375dfd2e992dac1e5341420cb0489d5" title="计算迭代器的正向索引">dllnk_index_of</a>(head, itr) != (size_t)(-1);
<a name="l00566"></a>00566 }
<a name="l00567"></a>00567 
<a name="l00574"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaab61b38bf3d3e3fd998f3df09b167a9d">00574</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaab61b38bf3d3e3fd998f3df09b167a9d" title="得到表首节点">dllnk_front</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00575"></a>00575 {
<a name="l00576"></a>00576     <span class="keywordflow">return</span> head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>;
<a name="l00577"></a>00577 }
<a name="l00578"></a>00578 
<a name="l00597"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae5f823311646f456d16de39ffcde80b7">00597</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gae5f823311646f456d16de39ffcde80b7" title="得到指向正向起始位置的迭代器">dllnk_begin</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00598"></a>00598 {
<a name="l00599"></a>00599     <span class="keywordflow">return</span> head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>;
<a name="l00600"></a>00600 }
<a name="l00601"></a>00601 
<a name="l00609"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gacf71befe2c0d81f78cc4758a75df63d1">00609</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gacf71befe2c0d81f78cc4758a75df63d1" title="得到指向正向终止位置的迭代器">dllnk_end</a>()
<a name="l00610"></a>00610 {
<a name="l00611"></a>00611     <span class="keywordflow">return</span> NULL;
<a name="l00612"></a>00612 }
<a name="l00613"></a>00613 
<a name="l00621"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga561b71db25d025ae7f75e673b75cd567">00621</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga561b71db25d025ae7f75e673b75cd567" title="得到当前迭代器的正向终止位置">dllnk_end_of</a>(dllnk_iter itr)
<a name="l00622"></a>00622 {
<a name="l00623"></a>00623     <span class="keywordflow">return</span> itr-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>;
<a name="l00624"></a>00624 }
<a name="l00625"></a>00625 
<a name="l00632"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga83d601c8b98ca875921d7e1bcfc597c8">00632</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga83d601c8b98ca875921d7e1bcfc597c8" title="得到当前节点的后继节点">dllnk_next</a>(dllnk_iter itr)
<a name="l00633"></a>00633 {
<a name="l00634"></a>00634     <span class="keywordflow">return</span> itr-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>;
<a name="l00635"></a>00635 }
<a name="l00636"></a>00636 
<a name="l00643"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaeffad2aa5e5b3d40a3a790a31d4a8c1c">00643</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaeffad2aa5e5b3d40a3a790a31d4a8c1c" title="得到当前节点的前驱节点">dllnk_prev</a>(dllnk_iter itr)
<a name="l00644"></a>00644 {
<a name="l00645"></a>00645     <span class="keywordflow">return</span> itr-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00646"></a>00646 }
<a name="l00647"></a>00647 
<a name="l00648"></a>00648 <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter __dllnk_inc_later(dllnk_iter cur, dllnk_iter* p)
<a name="l00649"></a>00649 {
<a name="l00650"></a>00650     *p = cur-&gt;<a class="code" href="struct____dllnk__node.html#a13509ef7669bb042eca96b48540099bf" title="后继节点">next</a>;
<a name="l00651"></a>00651     <span class="keywordflow">return</span> cur;
<a name="l00652"></a>00652 }
<a name="l00653"></a>00653 
<a name="l00654"></a>00654 <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter __dllnk_dec_later(dllnk_iter cur, dllnk_iter* p)
<a name="l00655"></a>00655 {
<a name="l00656"></a>00656     *p = cur-&gt;<a class="code" href="struct____dllnk__node.html#a4251ec9a3c71f24d5e15b60de3df48fb" title="前驱节点">prev</a>;
<a name="l00657"></a>00657     <span class="keywordflow">return</span> cur;
<a name="l00658"></a>00658 }
<a name="l00659"></a>00659 
<a name="l00670"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaf96c41737b8d631c6895026c3c29c9ed">00670</a> <span class="preprocessor">#define dllnk_inc(itr) ((itr) = (itr)-&gt;next)</span>
<a name="l00671"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga7a228a65239445ecffcfb2f3e6270d3f">00671</a> <span class="preprocessor"></span><span class="preprocessor">#define dllnk_dec(itr) ((itr) = (itr)-&gt;prev)</span>
<a name="l00672"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga39baf07fbf9c40367413e5d212557e74">00672</a> <span class="preprocessor"></span><span class="preprocessor">#define dllnk_inc_later(itr) __dllnk_inc_later(itr, &amp;(itr))</span>
<a name="l00673"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga587175a3674d02b79688b531a8be8672">00673</a> <span class="preprocessor"></span><span class="preprocessor">#define dllnk_dec_later(itr) __dllnk_dec_later(itr, &amp;(itr))</span>
<a name="l00674"></a>00674 <span class="preprocessor"></span>
<a name="l00684"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gad8243d398dc6e9b795a51e5b811fe491">00684</a> <span class="preprocessor">#define dllnk_foreach(_begin, _end, fn, type, member) \</span>
<a name="l00685"></a>00685 <span class="preprocessor">    do {dllnk_iter _q_e = (_end);                           \</span>
<a name="l00686"></a>00686 <span class="preprocessor">        dllnk_iter _q_f = (_begin);                         \</span>
<a name="l00687"></a>00687 <span class="preprocessor">        while (_q_f != _q_e) {                              \</span>
<a name="l00688"></a>00688 <span class="preprocessor">            type * _q_t = container_of(_q_f, type, member); \</span>
<a name="l00689"></a>00689 <span class="preprocessor">            _q_f = _q_f-&gt;next;                              \</span>
<a name="l00690"></a>00690 <span class="preprocessor">            fn(_q_t);                                       \</span>
<a name="l00691"></a>00691 <span class="preprocessor">        }                                                   \</span>
<a name="l00692"></a>00692 <span class="preprocessor">    } while (0)</span>
<a name="l00693"></a>00693 <span class="preprocessor"></span>
<a name="l00706"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaff6941fd85dec1f7998275b444bbab0f">00706</a> <span class="preprocessor">#define dllnk_search(head, _begin, _end, equal, var, res, type, member) \</span>
<a name="l00707"></a>00707 <span class="preprocessor">    do {dllnk_iter _q_e = (_end);                               \</span>
<a name="l00708"></a>00708 <span class="preprocessor">        dllnk_iter _q_f = (_begin);                             \</span>
<a name="l00709"></a>00709 <span class="preprocessor">        dllnk_head* _q_h = (head);                              \</span>
<a name="l00710"></a>00710 <span class="preprocessor">        (res) = NULL;                                           \</span>
<a name="l00711"></a>00711 <span class="preprocessor">        while (_q_f != _q_e) {                                  \</span>
<a name="l00712"></a>00712 <span class="preprocessor">            type * _q_cb = container_of(_q_f, type, member);    \</span>
<a name="l00713"></a>00713 <span class="preprocessor">            if (equal(_q_cb, (val))) {                          \</span>
<a name="l00714"></a>00714 <span class="preprocessor">                (res) = _q_cb;                                  \</span>
<a name="l00715"></a>00715 <span class="preprocessor">                break;                                          \</span>
<a name="l00716"></a>00716 <span class="preprocessor">            }                                                   \</span>
<a name="l00717"></a>00717 <span class="preprocessor">            _q_f = _q_f-&gt;next;                                  \</span>
<a name="l00718"></a>00718 <span class="preprocessor">        }                                                       \</span>
<a name="l00719"></a>00719 <span class="preprocessor">    } while (0)</span>
<a name="l00720"></a>00720 <span class="preprocessor"></span>
<a name="l00721"></a>00721 <span class="comment">/* 反转链表的两种方式：</span>
<a name="l00722"></a>00722 <span class="comment"> * (1) 直接使用 dllnk_reverse(head); (推荐)</span>
<a name="l00723"></a>00723 <span class="comment"> * (2) 按照如下方式迭代</span>
<a name="l00724"></a>00724 <span class="comment"> *     dllnk_iter i = dllnk_vbegin(head);</span>
<a name="l00725"></a>00725 <span class="comment"> *     dllnk_iter e = dllnk_vend(head);</span>
<a name="l00726"></a>00726 <span class="comment"> *     while (i != e) {</span>
<a name="l00727"></a>00727 <span class="comment"> *          dllnk_vpush(head, i);</span>
<a name="l00728"></a>00728 <span class="comment"> *     }</span>
<a name="l00729"></a>00729 <span class="comment"> *     当迭代完成时，反转完成</span>
<a name="l00730"></a>00730 <span class="comment"> */</span>
<a name="l00731"></a>00731 
<a name="l00732"></a>00732 <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter __dllnk_vbegin(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, dllnk_iter front)
<a name="l00733"></a>00733 {
<a name="l00734"></a>00734     head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a> = NULL;
<a name="l00735"></a>00735     <span class="keywordflow">return</span> front;
<a name="l00736"></a>00736 }
<a name="l00737"></a>00737 
<a name="l00754"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga668495163e8579cf93fda09f70dff68f">00754</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga668495163e8579cf93fda09f70dff68f" title="得到用于反转的起始位置的迭代器">dllnk_vbegin</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00755"></a>00755 {
<a name="l00756"></a>00756     <span class="keywordflow">return</span> __dllnk_vbegin(head, head-&gt;<a class="code" href="structdllnk__head.html#a91994daf5268f30717883dcc9f967c61" title="表首节点">front</a>);
<a name="l00757"></a>00757 }
<a name="l00758"></a>00758 
<a name="l00776"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9937303dbbaab3b5ab2f2c067256ab37">00776</a> <span class="keyword">static</span> <span class="keyword">inline</span> dllnk_iter <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga9937303dbbaab3b5ab2f2c067256ab37" title="得到用于反转的终止位置的迭代器">dllnk_vend</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head)
<a name="l00777"></a>00777 {
<a name="l00778"></a>00778     <span class="keywordflow">return</span> NULL;
<a name="l00779"></a>00779 }
<a name="l00780"></a>00780 
<a name="l00797"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga785922ebe4d1cc59203fcef25776c636">00797</a> <span class="preprocessor">#define dllnk_vpush(head, itr) dllnk_push_front(head, dllnk_inc_later(itr))</span>
<a name="l00798"></a>00798 <span class="preprocessor"></span>
<a name="l00805"></a>00805 NV_API <span class="keywordtype">void</span> <a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga7d2fa56b3cec32f03368f90abdb315df" title="反转表">dllnk_reverse</a>(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head);
<a name="l00806"></a>00806 
<a name="l00807"></a>00807 NV_API <span class="keywordtype">void</span> __dllnk_serialize(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, <span class="keywordtype">char</span>** buf, 
<a name="l00808"></a>00808                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> offset);
<a name="l00809"></a>00809 
<a name="l00810"></a>00810 NV_API <span class="keywordtype">void</span> __dllnk_deserialize(<a class="code" href="structdllnk__head.html" title="双向线形链表表头">dllnk_head</a>* head, <span class="keywordtype">char</span>** buf, 
<a name="l00811"></a>00811                             <span class="keywordtype">size_t</span> cnt, <span class="keyword">const</span> <span class="keywordtype">size_t</span> offset);
<a name="l00812"></a>00812 
<a name="l00842"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gacfa222816896d7f7b87ca37b57185bc9">00842</a> <span class="preprocessor">#define dllnk_serialize(head, buf, type, member) \</span>
<a name="l00843"></a>00843 <span class="preprocessor">    __dllnk_serialize(head, (char**)(buf), offset_of(type, member))</span>
<a name="l00844"></a>00844 <span class="preprocessor"></span>
<a name="l00875"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga1514d66dd9d06e311af3f5fa4baca309">00875</a> <span class="preprocessor">#define dllnk_deserialize(head, buf, cnt, type, member) \</span>
<a name="l00876"></a>00876 <span class="preprocessor">    __dllnk_deserialize(head, (char**)(buf), cnt, offset_of(type, member))</span>
<a name="l00877"></a>00877 <span class="preprocessor"></span>
<a name="l00889"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga7edc28c8c51ef2ee5abeaddaa98269d9">00889</a> <span class="preprocessor">#define dllnk_sort_insert(head, newly, greater_equal, type, member) do {\</span>
<a name="l00890"></a>00890 <span class="preprocessor">        dllnk_iter _k_n = (newly);                              \</span>
<a name="l00891"></a>00891 <span class="preprocessor">        dllnk_head* _k_h = (head);                              \</span>
<a name="l00892"></a>00892 <span class="preprocessor">        dllnk_iter _k_i = _k_h-&gt;next;                           \</span>
<a name="l00893"></a>00893 <span class="preprocessor">        while (_k_i) {                                          \</span>
<a name="l00894"></a>00894 <span class="preprocessor">            type * _k_pi = container_of(_k_i, type, member);    \</span>
<a name="l00895"></a>00895 <span class="preprocessor">            type * _k_pn = container_of(_k_n, type, member);    \</span>
<a name="l00896"></a>00896 <span class="preprocessor">            if (greater_equal(_k_pi, _k_pn))                    \</span>
<a name="l00897"></a>00897 <span class="preprocessor">                break;                                          \</span>
<a name="l00898"></a>00898 <span class="preprocessor">            _k_i = _k_i-&gt;next;                                  \</span>
<a name="l00899"></a>00899 <span class="preprocessor">        }                                                       \</span>
<a name="l00900"></a>00900 <span class="preprocessor">        dllnk_insert(_k_i, _k_n);                               \</span>
<a name="l00901"></a>00901 <span class="preprocessor">    } while (0)</span>
<a name="l00902"></a>00902 <span class="preprocessor"></span>
<a name="l00917"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga4bbbce0305bddd53a3a8f7745bb611a6">00917</a> <span class="preprocessor">#define dllnk_is_sorted(_begin, _end, greater_equal, res, type, member) do {\</span>
<a name="l00918"></a>00918 <span class="preprocessor">        dllnk_iter _k_e = (_end);                               \</span>
<a name="l00919"></a>00919 <span class="preprocessor">        dllnk_iter _k_i = (_begin);                             \</span>
<a name="l00920"></a>00920 <span class="preprocessor">        dllnk_iter _k_j = _k_i-&gt;next;                           \</span>
<a name="l00921"></a>00921 <span class="preprocessor">        (res) = 1;                                              \</span>
<a name="l00922"></a>00922 <span class="preprocessor">        while (_k_j != _k_e) {                                  \</span>
<a name="l00923"></a>00923 <span class="preprocessor">            type * _k_pi = container_of(_k_i, type, member);    \</span>
<a name="l00924"></a>00924 <span class="preprocessor">            type * _k_pj = container_of(_k_j, type, member);    \</span>
<a name="l00925"></a>00925 <span class="preprocessor">            if (!(greater_equal(_k_pj, _k_pi))) {               \</span>
<a name="l00926"></a>00926 <span class="preprocessor">                (res) = 0;                                      \</span>
<a name="l00927"></a>00927 <span class="preprocessor">                break;                                          \</span>
<a name="l00928"></a>00928 <span class="preprocessor">            }                                                   \</span>
<a name="l00929"></a>00929 <span class="preprocessor">            _k_i = _k_j;                                        \</span>
<a name="l00930"></a>00930 <span class="preprocessor">            _k_j = _k_j-&gt;next;                                  \</span>
<a name="l00931"></a>00931 <span class="preprocessor">        }                                                       \</span>
<a name="l00932"></a>00932 <span class="preprocessor">    } while (0)</span>
<a name="l00933"></a>00933 <span class="preprocessor"></span>
<a name="l00934"></a>00934 <span class="comment">/* 双向线形链表排序性能比较</span>
<a name="l00935"></a>00935 <span class="comment"> * 随机数据：(最高) 插入排序 &gt;&gt; 选择排序 &gt;&gt; 冒泡排序 &gt; 鸡尾酒排序 &gt; 奇偶排序 (最低)</span>
<a name="l00936"></a>00936 <span class="comment"> * 顺序数据：(最高) 冒泡排序 &gt; 奇偶排序 &gt; 鸡尾酒排序 &gt;&gt; 插入排序 &gt; 选择排序  (最低)</span>
<a name="l00937"></a>00937 <span class="comment"> * 逆序数据：(最高) 插入排序 &gt;&gt; 选择排序 &gt;&gt; 冒泡排序 &gt; 鸡尾酒排序 &gt; 奇偶排序  (最低)</span>
<a name="l00938"></a>00938 <span class="comment"> */</span>
<a name="l00939"></a>00939 
<a name="l00952"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gac439692afec5b3becd5dbabdee620a6f">00952</a> <span class="preprocessor">#define dllnk_bubble_sort(_begin, _end, greater, type, member) do { \</span>
<a name="l00953"></a>00953 <span class="preprocessor">        int _k_pc = 1;                                              \</span>
<a name="l00954"></a>00954 <span class="preprocessor">        dllnk_iter _k_e = (_end);                                   \</span>
<a name="l00955"></a>00955 <span class="preprocessor">        dllnk_iter _k_i = (_begin);                                 \</span>
<a name="l00956"></a>00956 <span class="preprocessor">        for (; _k_pc &amp;&amp; _k_i != _k_e; _k_i = _k_i-&gt;next) {          \</span>
<a name="l00957"></a>00957 <span class="preprocessor">            dllnk_iter _k_j = _k_i-&gt;next;                           \</span>
<a name="l00958"></a>00958 <span class="preprocessor">            for (_k_pc = 0; _k_j != _k_e; _k_j = _k_j-&gt;next) {      \</span>
<a name="l00959"></a>00959 <span class="preprocessor">                type * _k_pi = container_of(_k_i, type, member);    \</span>
<a name="l00960"></a>00960 <span class="preprocessor">                type * _k_pj = container_of(_k_j, type, member);    \</span>
<a name="l00961"></a>00961 <span class="preprocessor">                if (greater(_k_pi, _k_pj)) {                        \</span>
<a name="l00962"></a>00962 <span class="preprocessor">                    dllnk_iter _k_t = _k_i;                         \</span>
<a name="l00963"></a>00963 <span class="preprocessor">                    _k_i = _k_j;                                    \</span>
<a name="l00964"></a>00964 <span class="preprocessor">                    _k_j = _k_t;                                    \</span>
<a name="l00965"></a>00965 <span class="preprocessor">                    dllnk_iter_swap(_k_i, _k_j);                    \</span>
<a name="l00966"></a>00966 <span class="preprocessor">                    _k_pc = 1;                                      \</span>
<a name="l00967"></a>00967 <span class="preprocessor">                }                                                   \</span>
<a name="l00968"></a>00968 <span class="preprocessor">            }                                                       \</span>
<a name="l00969"></a>00969 <span class="preprocessor">        }                                                           \</span>
<a name="l00970"></a>00970 <span class="preprocessor">    } while (0)</span>
<a name="l00971"></a>00971 <span class="preprocessor"></span>
<a name="l00984"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gad5d51c77ceafbcdaa61868619442c637">00984</a> <span class="preprocessor">#define dllnk_oddeven_sort(_begin, _end, greater, type, member) do {    \</span>
<a name="l00985"></a>00985 <span class="preprocessor">        int _k_pc = 1;                                                  \</span>
<a name="l00986"></a>00986 <span class="preprocessor">        dllnk_iter _k_e = (_end);                                       \</span>
<a name="l00987"></a>00987 <span class="preprocessor">        dllnk_iter _k_f = (_begin);                                     \</span>
<a name="l00988"></a>00988 <span class="preprocessor">        dllnk_iter _k_p = _k_f-&gt;prev;                                   \</span>
<a name="l00989"></a>00989 <span class="preprocessor">        while (_k_pc) {                                                 \</span>
<a name="l00990"></a>00990 <span class="preprocessor">            _k_pc = 0;                                                  \</span>
<a name="l00991"></a>00991 <span class="preprocessor">            _k_f = _k_p-&gt;next;                                          \</span>
<a name="l00992"></a>00992 <span class="preprocessor">            __dllnk_oddeven_scan(greater, type, member, _k_f);          \</span>
<a name="l00993"></a>00993 <span class="preprocessor">            __dllnk_oddeven_scan(greater, type, member, _k_f-&gt;next);    \</span>
<a name="l00994"></a>00994 <span class="preprocessor">        }                                                               \</span>
<a name="l00995"></a>00995 <span class="preprocessor">    } while (0)</span>
<a name="l00996"></a>00996 <span class="preprocessor"></span>
<a name="l00997"></a>00997 <span class="preprocessor">#define __dllnk_oddeven_scan(greater, type, member, _start) do {    \</span>
<a name="l00998"></a>00998 <span class="preprocessor">        dllnk_iter _k_i = _start;                                   \</span>
<a name="l00999"></a>00999 <span class="preprocessor">        dllnk_iter _k_j = _k_i-&gt;next;                               \</span>
<a name="l01000"></a>01000 <span class="preprocessor">        while (_k_j != _k_e) {                                      \</span>
<a name="l01001"></a>01001 <span class="preprocessor">            type * _k_pi = container_of(_k_i, type, member);        \</span>
<a name="l01002"></a>01002 <span class="preprocessor">            type * _k_pj = container_of(_k_j, type, member);        \</span>
<a name="l01003"></a>01003 <span class="preprocessor">            if (greater(_k_pi, _k_pj)) {                            \</span>
<a name="l01004"></a>01004 <span class="preprocessor">                dllnk_iter _k_t = _k_i;                             \</span>
<a name="l01005"></a>01005 <span class="preprocessor">                _k_i = _k_j;                                        \</span>
<a name="l01006"></a>01006 <span class="preprocessor">                _k_j = _k_t;                                        \</span>
<a name="l01007"></a>01007 <span class="preprocessor">                dllnk_iter_swap(_k_i, _k_j);                        \</span>
<a name="l01008"></a>01008 <span class="preprocessor">                _k_pc = 1;                                          \</span>
<a name="l01009"></a>01009 <span class="preprocessor">            }                                                       \</span>
<a name="l01010"></a>01010 <span class="preprocessor">            if (!_k_j) break;                                       \</span>
<a name="l01011"></a>01011 <span class="preprocessor">            _k_i = _k_j-&gt;next;                                      \</span>
<a name="l01012"></a>01012 <span class="preprocessor">            if (!_k_i) break;                                       \</span>
<a name="l01013"></a>01013 <span class="preprocessor">            _k_j = _k_i-&gt;next;                                      \</span>
<a name="l01014"></a>01014 <span class="preprocessor">        }                                                           \</span>
<a name="l01015"></a>01015 <span class="preprocessor">    } while (0)</span>
<a name="l01016"></a>01016 <span class="preprocessor"></span>
<a name="l01029"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga682c2252436a3180dc8c98faf50afd20">01029</a> <span class="preprocessor">#define dllnk_cocktail_sort(_begin, _end, greater, type, member) do {   \</span>
<a name="l01030"></a>01030 <span class="preprocessor">        int _k_pc = 1;                                                  \</span>
<a name="l01031"></a>01031 <span class="preprocessor">        dllnk_iter _k_e = (_end);                                       \</span>
<a name="l01032"></a>01032 <span class="preprocessor">        dllnk_iter _k_f = (_begin);                                     \</span>
<a name="l01033"></a>01033 <span class="preprocessor">        while (_k_pc) {                                                 \</span>
<a name="l01034"></a>01034 <span class="preprocessor">            dllnk_iter _k_i = _k_f;                                     \</span>
<a name="l01035"></a>01035 <span class="preprocessor">            dllnk_iter _k_j = _k_f-&gt;next;                               \</span>
<a name="l01036"></a>01036 <span class="preprocessor">            _k_pc = 0;                                                  \</span>
<a name="l01037"></a>01037 <span class="preprocessor">            if (_k_j != _k_e) {                                         \</span>
<a name="l01038"></a>01038 <span class="preprocessor">                type * _k_pj = container_of(_k_j, type, member);        \</span>
<a name="l01039"></a>01039 <span class="preprocessor">                type * _k_pi = container_of(_k_i, type, member);        \</span>
<a name="l01040"></a>01040 <span class="preprocessor">                if (greater(_k_pi, _k_pj)) {                            \</span>
<a name="l01041"></a>01041 <span class="preprocessor">                    dllnk_iter _k_t = _k_i;                             \</span>
<a name="l01042"></a>01042 <span class="preprocessor">                    _k_i = _k_j;                                        \</span>
<a name="l01043"></a>01043 <span class="preprocessor">                    _k_f = _k_j;                                        \</span>
<a name="l01044"></a>01044 <span class="preprocessor">                    _k_j = _k_t;                                        \</span>
<a name="l01045"></a>01045 <span class="preprocessor">                    dllnk_iter_swap(_k_i, _k_j);                        \</span>
<a name="l01046"></a>01046 <span class="preprocessor">                    _k_pc = 1;                                          \</span>
<a name="l01047"></a>01047 <span class="preprocessor">                }                                                       \</span>
<a name="l01048"></a>01048 <span class="preprocessor">                _k_i = _k_j;                                            \</span>
<a name="l01049"></a>01049 <span class="preprocessor">                _k_j = _k_j-&gt;next;                                      \</span>
<a name="l01050"></a>01050 <span class="preprocessor">            }                                                           \</span>
<a name="l01051"></a>01051 <span class="preprocessor">            while (_k_j != _k_e) {                                      \</span>
<a name="l01052"></a>01052 <span class="preprocessor">                type * _k_pj = container_of(_k_j, type, member);        \</span>
<a name="l01053"></a>01053 <span class="preprocessor">                type * _k_pi = container_of(_k_i, type, member);        \</span>
<a name="l01054"></a>01054 <span class="preprocessor">                if (greater(_k_pi, _k_pj)) {                            \</span>
<a name="l01055"></a>01055 <span class="preprocessor">                    dllnk_iter _k_t = _k_i;                             \</span>
<a name="l01056"></a>01056 <span class="preprocessor">                    _k_i = _k_j;                                        \</span>
<a name="l01057"></a>01057 <span class="preprocessor">                    _k_j = _k_t;                                        \</span>
<a name="l01058"></a>01058 <span class="preprocessor">                    dllnk_iter_swap(_k_i, _k_j);                        \</span>
<a name="l01059"></a>01059 <span class="preprocessor">                    _k_pc = 1;                                          \</span>
<a name="l01060"></a>01060 <span class="preprocessor">                }                                                       \</span>
<a name="l01061"></a>01061 <span class="preprocessor">                _k_i = _k_j;                                            \</span>
<a name="l01062"></a>01062 <span class="preprocessor">                _k_j = _k_j-&gt;next;                                      \</span>
<a name="l01063"></a>01063 <span class="preprocessor">            }                                                           \</span>
<a name="l01064"></a>01064 <span class="preprocessor">            _k_i = _k_i-&gt;prev;                                          \</span>
<a name="l01065"></a>01065 <span class="preprocessor">            _k_j = _k_i-&gt;prev;                                          \</span>
<a name="l01066"></a>01066 <span class="preprocessor">            _k_f = _k_f-&gt;prev;                                          \</span>
<a name="l01067"></a>01067 <span class="preprocessor">            while (_k_j != _k_f) {                                      \</span>
<a name="l01068"></a>01068 <span class="preprocessor">                type * _k_pi = container_of(_k_i, type, member);        \</span>
<a name="l01069"></a>01069 <span class="preprocessor">                type * _k_pj = container_of(_k_j, type, member);        \</span>
<a name="l01070"></a>01070 <span class="preprocessor">                if (greater(_k_pj, _k_pi)) {                            \</span>
<a name="l01071"></a>01071 <span class="preprocessor">                    dllnk_iter _k_t = _k_i;                             \</span>
<a name="l01072"></a>01072 <span class="preprocessor">                    _k_i = _k_j;                                        \</span>
<a name="l01073"></a>01073 <span class="preprocessor">                    _k_j = _k_t;                                        \</span>
<a name="l01074"></a>01074 <span class="preprocessor">                    dllnk_iter_swap(_k_i, _k_j);                        \</span>
<a name="l01075"></a>01075 <span class="preprocessor">                    _k_pc = 1;                                          \</span>
<a name="l01076"></a>01076 <span class="preprocessor">                }                                                       \</span>
<a name="l01077"></a>01077 <span class="preprocessor">                _k_i = _k_j;                                            \</span>
<a name="l01078"></a>01078 <span class="preprocessor">                _k_j = _k_j-&gt;prev;                                      \</span>
<a name="l01079"></a>01079 <span class="preprocessor">            }                                                           \</span>
<a name="l01080"></a>01080 <span class="preprocessor">            _k_f = _k_f-&gt;next;                                          \</span>
<a name="l01081"></a>01081 <span class="preprocessor">        }                                                               \</span>
<a name="l01082"></a>01082 <span class="preprocessor">    } while (0)</span>
<a name="l01083"></a>01083 <span class="preprocessor"></span>
<a name="l01096"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#gaa83554627bdbd917023fdaf55a5cf5bd">01096</a> <span class="preprocessor">#define dllnk_select_sort(_begin, _end, greater, type, member) do { \</span>
<a name="l01097"></a>01097 <span class="preprocessor">        dllnk_iter _k_e = (_end);                                   \</span>
<a name="l01098"></a>01098 <span class="preprocessor">        dllnk_iter _k_i = (_begin);                                 \</span>
<a name="l01099"></a>01099 <span class="preprocessor">        dllnk_iter _k_j = _k_i-&gt;next;                               \</span>
<a name="l01100"></a>01100 <span class="preprocessor">        while (_k_j != _k_e) {                                      \</span>
<a name="l01101"></a>01101 <span class="preprocessor">            dllnk_iter _k_m = _k_i;                                 \</span>
<a name="l01102"></a>01102 <span class="preprocessor">            while (_k_j != _k_e) {                                  \</span>
<a name="l01103"></a>01103 <span class="preprocessor">                type * _k_pj = container_of(_k_j, type, member);    \</span>
<a name="l01104"></a>01104 <span class="preprocessor">                type * _k_pm = container_of(_k_m, type, member);    \</span>
<a name="l01105"></a>01105 <span class="preprocessor">                if (greater(_k_pm, _k_pj))                          \</span>
<a name="l01106"></a>01106 <span class="preprocessor">                    _k_m = _k_j;                                    \</span>
<a name="l01107"></a>01107 <span class="preprocessor">                _k_j = _k_j-&gt;next;                                  \</span>
<a name="l01108"></a>01108 <span class="preprocessor">            }                                                       \</span>
<a name="l01109"></a>01109 <span class="preprocessor">            if (_k_i != _k_m) {                                     \</span>
<a name="l01110"></a>01110 <span class="preprocessor">                dllnk_iter _k_t = _k_m;                             \</span>
<a name="l01111"></a>01111 <span class="preprocessor">                _k_m = _k_i;                                        \</span>
<a name="l01112"></a>01112 <span class="preprocessor">                _k_i = _k_t;                                        \</span>
<a name="l01113"></a>01113 <span class="preprocessor">                dllnk_iter_swap(_k_m, _k_i);                        \</span>
<a name="l01114"></a>01114 <span class="preprocessor">            }                                                       \</span>
<a name="l01115"></a>01115 <span class="preprocessor">            _k_i = _k_i-&gt;next;                                      \</span>
<a name="l01116"></a>01116 <span class="preprocessor">            _k_j = _k_i-&gt;next;                                      \</span>
<a name="l01117"></a>01117 <span class="preprocessor">        }                                                           \</span>
<a name="l01118"></a>01118 <span class="preprocessor">    } while (0)</span>
<a name="l01119"></a>01119 <span class="preprocessor"></span>
<a name="l01132"></a><a class="code" href="group___xE5_x8F_x8C_xE5_x90_x91_xE7_xBA_xBF_xE5_xBD_xA2_xE9_x93_xBE_xE8_xA1_xA8.html#ga1a256df2453272c4108accd43e4373a6">01132</a> <span class="preprocessor">#define dllnk_insert_sort(_begin, _end, greater_equal, type, member) do {\</span>
<a name="l01133"></a>01133 <span class="preprocessor">        dllnk_iter _k_e = (_end);                                       \</span>
<a name="l01134"></a>01134 <span class="preprocessor">        dllnk_iter _k_f = (_begin);                                     \</span>
<a name="l01135"></a>01135 <span class="preprocessor">        dllnk_iter _k_i = _k_f-&gt;next;                                   \</span>
<a name="l01136"></a>01136 <span class="preprocessor">        for (_k_f = _k_f-&gt;prev; _k_i != _k_e; _k_i = _k_i-&gt;next) {      \</span>
<a name="l01137"></a>01137 <span class="preprocessor">            type * _k_pi = container_of(_k_i, type, member);            \</span>
<a name="l01138"></a>01138 <span class="preprocessor">            dllnk_iter _k_j = _k_f-&gt;next;                               \</span>
<a name="l01139"></a>01139 <span class="preprocessor">            while (_k_j != _k_i) {                                      \</span>
<a name="l01140"></a>01140 <span class="preprocessor">                type * _k_pj = container_of(_k_j, type, member);        \</span>
<a name="l01141"></a>01141 <span class="preprocessor">                if (greater_equal(_k_pj, _k_pi)) {                      \</span>
<a name="l01142"></a>01142 <span class="preprocessor">                    dllnk_iter _k_t = _k_i;                             \</span>
<a name="l01143"></a>01143 <span class="preprocessor">                    _k_i = _k_i-&gt;prev;                                  \</span>
<a name="l01144"></a>01144 <span class="preprocessor">                    dllnk_erase(_k_t);                                  \</span>
<a name="l01145"></a>01145 <span class="preprocessor">                    dllnk_insert(_k_j, _k_t);                           \</span>
<a name="l01146"></a>01146 <span class="preprocessor">                    break;                                              \</span>
<a name="l01147"></a>01147 <span class="preprocessor">                }                                                       \</span>
<a name="l01148"></a>01148 <span class="preprocessor">                _k_j = _k_j-&gt;next;                                      \</span>
<a name="l01149"></a>01149 <span class="preprocessor">            }                                                           \</span>
<a name="l01150"></a>01150 <span class="preprocessor">        }                                                               \</span>
<a name="l01151"></a>01151 <span class="preprocessor">    } while (0)</span>
<a name="l01152"></a>01152 <span class="preprocessor"></span>
<a name="l01155"></a>01155 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l01156"></a>01156 <span class="preprocessor"></span>}
<a name="l01157"></a>01157 <span class="preprocessor">#endif </span><span class="comment">/* #ifdef __cplusplus */</span>
<a name="l01158"></a>01158 
<a name="l01159"></a>01159 <span class="preprocessor">#endif </span><span class="comment">/* #ifndef __NV_DLLNK__ */</span>
</pre></div></div>
</div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>数据结构</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>类型定义</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Generated at 2015年七月16日 星期四 12:00:37 for Navo Portable Library by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
